package com.heu.blood.globalExceptionHandler;

import com.heu.blood.common.utils.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * 功能描述：全局异常处理器
 *
 * @Author: lvyj
 * @Date: 2024/6/29 14:24
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 处理字典模块的业务异常
     * @param req
     * @param e
     * @return
     */
    @ExceptionHandler(value = MyException.class)
    @ResponseBody
    public R bizExceptionHandler(HttpServletRequest req, MyException e){
        return R.error(e.getResultCode(),e.getResultMsg());
    }
}
